<?php
$space = Blyn::app()->getActiveSpace();
$userRoles = BRole::findUserRoles(NULL, array('spaceId' => $space->getId()), FALSE, TRUE);
?>
<style>
    #ajax-loaderdiv {position: fixed;top: 0;left: 0;width: 100%;height: 100%;z-index: 35000;background-color: rgba(0, 0, 0, 0.3);display: none;}
    .ajax-loader {position: absolute;left: 50%;top: 50%;margin-left: -16px;margin-top: -16px;display: block;}
</style>
<div id="ajax-loaderdiv" style="display: none;">
    <img src="/billyn-dev/images/ajax-loader.gif" class="ajax-loader">
</div>
<div class="container">
    <h3 class="form-signin-heading text-muted"><?php echo '我的会员资格'; ?></h3>
    <div class="displayUserInfo">
        <table class="table table-striped">
            <thead>
                <tr>
                    <th>应用名</th>
                    <th>角色</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <?php
                foreach ($userRoles as $role) {
                    $roleName = $role->getName();
                    if ($roleName == 'all_roles')
                        continue;
                    $roleFullName = $role->getFullName();
                    $appId = $role->appId;
                    $appClass = 'BApp';
                    if ($appId > 0) {
                        $app = bapp::getAppById($appId);
                        $appClass = get_class($app);
                    }
                    ?>
                    <tr>
                        <td><?php echo $appClass; ?></td>
                        <td><?php
                            //echo $roleName; 
                            echo BUIRole::getRoleAliasByFullName($roleFullName);
                            ?></td>
                        <td><?php
                            echo $control->getAjaxLink(array(
                                'name' => '退出', 'id' => 'deleteUserRole'), array(
                                'roleId' => $role->getId()));
                            ?>
                        </td>
                    </tr>
                <?php } ?>
            </tbody>
        </table>
    </div>
    <div class="displayUserInfo">
        <?php
        echo $control->getAjaxLink('申请权限', array(
            'cooker' => 'BARoleCooker@showApplyRole',
            'htmlOptions' => array(
                'class' => 'btn btn-success btn-lg btn-block'
        )));
        ?>
        <?php
        echo $control->getAjaxLink(array('name' => '用户信息', 'id' => BUIUser::Render_Display_UserInfo), array('htmlOptions' => array(
                'class' => 'btn btn-info btn-lg btn-block'
        )));
        ?>

    </div>
</div>

